#include <iostream>
#include "Shm.hpp"
#include "namedPipe.hpp"

int main()
{
    // 获得共享内存
    Shm shm(gPathName, gProj_id, gUser);
    char* shmadd = (char*)shm.Addr();

    // 打开管道
    NamedPipe fifo(gPathname, User);
    fifo.OpenForWrite();

    // 写入数据
    char ch = 'A';
    while(ch <= 'Z')
    {
        // 向共享内存写入数据
        shmadd[ch - 'A'] = ch;
        // 利用管道进程同步
        std::string tmp = "wakeup";
        std::cout << "add " << ch << " into Shm, " << "wakeup reader" << std::endl;
        fifo.WriteNamedPipe(tmp);
        
        ch++;
        sleep(2);
    }
    return 0;
}